using System;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
    /**
     * Classname : Report
     * Version information :1.0
     * Date  :26-09-2006
     * Copyright notice : 
     */

    public class DAReport : DbObject
    {
        protected SqlConnection connec;

        public DAReport(SqlConnection Connection)
		{
            connec = Connection;
		}
        //load hocvien by level
        public DataSet loadHocVienByLevel(int NguoidungID,int LevelID)
        {
            SqlParameter[] parameters =  {	 new SqlParameter("@NguoidungID", SqlDbType.Int,4 ), 
                                             new SqlParameter("@LevelID", SqlDbType.Int,4 ) 
                                         };
            // set the 0values
            parameters[0].Value = NguoidungID;
            parameters[1].Value = LevelID;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23_loadHocVienByLevel", parameters, "TB_ReportS23", connec);
            return dsHocVien;
        }
        //load hocvien by nguoidung
        public DataTable loadHocvienByNguoidung(int NguoidungID)
        {
            DataTable dtData = new DataTable();
            SqlParameter[] parameters =  {	 new SqlParameter("@NguoidungID", SqlDbType.Int,4 )
                                         };
            // set the 0values
            parameters[0].Value = NguoidungID;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23_loadHocvienByNguoidung", parameters, "TB_ReportS23", connec);
            if (dsHocVien != null && dsHocVien.Tables[0] != null)
            {
                dtData = dsHocVien.Tables[0];
            }
            return dtData;
        }
       
        #region "Report S23"
        //Lay du lieu cho trang bao cao 1
        public DataTable getDataHistoryByDate(DateTime Date)
        {
            DataTable dtData = new DataTable();
            SqlParameter[] parameters =  {	 new SqlParameter("@Date", SqlDbType.DateTime)
                                         };
            // set the 0values
            parameters[0].Value = Date;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23_getDataFirstPage", parameters, "TB_ReportS23", connec);
            if (dsHocVien != null && dsHocVien.Tables[0] != null)
            {
                dtData = dsHocVien.Tables[0];
            }
            return dtData;
        }
        public DataSet loadReportHocVien(int NguoidungID)
        {
            SqlParameter[] parameters =  {	 new SqlParameter("@NguoidungID", SqlDbType.Int,4 )
                                         };
            // set the 0values
            parameters[0].Value = NguoidungID;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23_loadReportHocVien", parameters, "TB_ReportS23", connec);
            return dsHocVien;
        }
        public int insertReportS23(int NguoiDungID, int SLT, int Lx1, int Lx2, int Lx3, int LevelID, DateTime date, SqlTransaction sqlTransaction)
        {
            int numAffected = 0;
            // create the parameters
            SqlParameter[] parameters =  {	    
                                                new SqlParameter("@NguoiDungID", SqlDbType.Int,4),
                                                new SqlParameter("@SLT", SqlDbType.Int,4),
                                                new SqlParameter("@Lx1", SqlDbType.Int,4),
                                                new SqlParameter("@Lx2", SqlDbType.Int,4),
                                                new SqlParameter("@Lx3", SqlDbType.Int,4),
                                                new SqlParameter("@LevelID", SqlDbType.Int,4),
                                                new SqlParameter("@Date", SqlDbType.DateTime)                                            
										 };
            // set the 0values
            parameters[0].Value = NguoiDungID;
            parameters[1].Value = SLT;
            parameters[2].Value = Lx1;
            parameters[3].Value = Lx2;
            parameters[4].Value = Lx3;
            parameters[5].Value = LevelID;
            parameters[6].Value = date;
            // run the procedure
            //RunProcedureWithTrans("sp_ReportS23_Insert", parameters, out numAffected, sqlTransaction);
            RunProcedure("sp_ReportS23_Insert", parameters, out numAffected, connec);
            return numAffected;
        }
        //Dem so hoc vien
        public int loadDemSoHocVienTheoNguoiDungReportS23(int NguoiDungID, int LevelID)
        {
            int numAffected;
            SqlParameter[] parameters = {   new SqlParameter("@NguoiDungID", SqlDbType.Int, 4),
                                            new SqlParameter("@LevelID", SqlDbType.Int, 4) 
                                        };
            parameters[0].Value = NguoiDungID;
            parameters[1].Value = LevelID;

            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23_loadDemSoHocVienTheoThaiGoiByLevel", parameters, "TB_ReportS23", connec);
            if (dsHocVien != null && dsHocVien.Tables[0].Rows.Count > 0)
            {
                numAffected = Convert.ToInt32(dsHocVien.Tables[0].Rows[0]["Tong"].ToString());
            }
            else
            {
                numAffected = 0;
            }
            return numAffected;
        }
        //Lay danh sach lich su ngay bao cao
        public DataTable getHistoryDate()
        {
            DataTable dtData = new DataTable();
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23_GetDistinctDate", "TB_ReportS23", connec);
            if (dsHocVien != null && dsHocVien.Tables[0] != null)
            {
                dtData = dsHocVien.Tables[0];
            }
            return dtData;
        }
        #endregion

        #region "Report S23S"
        //Lay du lieu cho trang bao cao 1
        public DataTable getDataHistoryByDate23S(DateTime Date)
        {
            DataTable dtData = new DataTable();
            SqlParameter[] parameters =  {	 new SqlParameter("@Date", SqlDbType.DateTime)
                                         };
            // set the 0values
            parameters[0].Value = Date;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23S_getDataFirstPage", parameters, "TB_ReportS23S", connec);
            if (dsHocVien != null && dsHocVien.Tables[0] != null)
            {
                dtData = dsHocVien.Tables[0];
            }
            return dtData;
        }
        public DataSet loadReportHocVien23S(int NguoidungID,int NguonID)
        {
            SqlParameter[] parameters =  {	 new SqlParameter("@NguoidungID", SqlDbType.Int,4 )
                                         };
            // set the 0values
            parameters[0].Value = NguoidungID;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23S_loadReportHocVien", parameters, "TB_ReportS23S", connec);
            return dsHocVien;
        }
        public int insertReportS23S(int NguoiDungID, int SLT, int Lx1, int Lx2, int Lx3, int LevelID, DateTime date, SqlTransaction sqlTransaction, int NguonID)
        {
            int numAffected = 0;
            // create the parameters
            SqlParameter[] parameters =  {	    
                                                new SqlParameter("@NguoiDungID", SqlDbType.Int,4),
                                                new SqlParameter("@SLT", SqlDbType.Int,4),
                                                new SqlParameter("@Lx1", SqlDbType.Int,4),
                                                new SqlParameter("@Lx2", SqlDbType.Int,4),
                                                new SqlParameter("@Lx3", SqlDbType.Int,4),
                                                new SqlParameter("@LevelID", SqlDbType.Int,4),
                                                new SqlParameter("@Date", SqlDbType.DateTime)    ,
                                                new SqlParameter("@NguonID", SqlDbType.Int,4)                                        
										 };
            // set the 0values
            parameters[0].Value = NguoiDungID;
            parameters[1].Value = SLT;
            parameters[2].Value = Lx1;
            parameters[3].Value = Lx2;
            parameters[4].Value = Lx3;
            parameters[5].Value = LevelID;
            parameters[6].Value = date;
            parameters[7].Value = NguonID;
            // run the procedure
            //RunProcedureWithTrans("sp_ReportS23_Insert", parameters, out numAffected, sqlTransaction);
            RunProcedure("sp_ReportS23S_Insert", parameters, out numAffected, connec);
            return numAffected;
        }
        //Dem so hoc vien
        public int loadDemSoHocVienTheoNguoiDungReportS23S(int NguoiDungID, int LevelID, int NguonID)
        {
            int numAffected;
            SqlParameter[] parameters = {   new SqlParameter("@NguoiDungID", SqlDbType.Int, 4),
                                            new SqlParameter("@LevelID", SqlDbType.Int, 4) 
                                        };
            parameters[0].Value = NguoiDungID;
            parameters[1].Value = LevelID;

            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23S_loadDemSoHocVienTheoThaiGoiByLevel", parameters, "TB_ReportS23S", connec);
            if (dsHocVien != null && dsHocVien.Tables[0].Rows.Count > 0)
            {
                numAffected = Convert.ToInt32(dsHocVien.Tables[0].Rows[0]["Tong"].ToString());
            }
            else
            {
                numAffected = 0;
            }
            return numAffected;
        }
        //Lay danh sach lich su ngay bao cao
        public DataTable getHistoryDate23S(int NguonID)
        {
            DataTable dtData = new DataTable();
            SqlParameter[] parameters = {   new SqlParameter("@NguonID", SqlDbType.Int, 4) 
                                        };
            parameters[0].Value = NguonID;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23S_GetDistinctDate",parameters, "TB_ReportS23S", connec);
            if (dsHocVien != null && dsHocVien.Tables[0] != null)
            {
                dtData = dsHocVien.Tables[0];
            }
            return dtData;
        }
        #endregion

        #region "Report S23STruong"
        //Lay du lieu cho trang bao cao 1
        public DataTable getDataHistoryByDate23STruong(DateTime Date)
        {
            DataTable dtData = new DataTable();
            SqlParameter[] parameters =  {	 new SqlParameter("@Date", SqlDbType.DateTime)
                                         };
            // set the 0values
            parameters[0].Value = Date;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23STruong_getDataFirstPage", parameters, "TB_ReportS23STruong", connec);
            if (dsHocVien != null && dsHocVien.Tables[0] != null)
            {
                dtData = dsHocVien.Tables[0];
            }
            return dtData;
        }
        public DataSet loadReportHocVien23STruong(int NguoidungID, int NguonID, int TruongID)
        {
            SqlParameter[] parameters =  {	 new SqlParameter("@NguoidungID", SqlDbType.Int,4 )
                                         };
            // set the 0values
            parameters[0].Value = NguoidungID;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23STruong_loadReportHocVien", parameters, "TB_ReportS23STruong", connec);
            return dsHocVien;
        }
        public int insertReportS23STruong(int NguoiDungID, int SLT, int Lx1, int Lx2, int Lx3, int LevelID, DateTime date, SqlTransaction sqlTransaction, int NguonID, int TruongID)
        {
            int numAffected = 0;
            // create the parameters
            SqlParameter[] parameters =  {	    
                                                new SqlParameter("@NguoiDungID", SqlDbType.Int,4),
                                                new SqlParameter("@SLT", SqlDbType.Int,4),
                                                new SqlParameter("@Lx1", SqlDbType.Int,4),
                                                new SqlParameter("@Lx2", SqlDbType.Int,4),
                                                new SqlParameter("@Lx3", SqlDbType.Int,4),
                                                new SqlParameter("@LevelID", SqlDbType.Int,4),
                                                new SqlParameter("@Date", SqlDbType.DateTime)    ,
                                                new SqlParameter("@NguonID", SqlDbType.Int,4),
                                                new SqlParameter("@TruongID", SqlDbType.Int,4)
										 };
            // set the 0values
            parameters[0].Value = NguoiDungID;
            parameters[1].Value = SLT;
            parameters[2].Value = Lx1;
            parameters[3].Value = Lx2;
            parameters[4].Value = Lx3;
            parameters[5].Value = LevelID;
            parameters[6].Value = date;
            parameters[7].Value = NguonID;
            parameters[8].Value = TruongID;
            // run the procedure
            //RunProcedureWithTrans("sp_ReportS23_Insert", parameters, out numAffected, sqlTransaction);
            RunProcedure("sp_ReportS23STruong_Insert", parameters, out numAffected, connec);
            return numAffected;
        }
        //Dem so hoc vien
        public int loadDemSoHocVienTheoNguoiDungReportS23STruong(int NguoiDungID, int LevelID, int NguonID, int TruongID)
        {
            int numAffected;
            SqlParameter[] parameters = {   new SqlParameter("@NguoiDungID", SqlDbType.Int, 4),
                                            new SqlParameter("@LevelID", SqlDbType.Int, 4) 
                                        };
            parameters[0].Value = NguoiDungID;
            parameters[1].Value = LevelID;

            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23STruong_loadDemSoHocVienTheoThaiGoiByLevel", parameters, "TB_ReportS23STruong", connec);
            if (dsHocVien != null && dsHocVien.Tables[0].Rows.Count > 0)
            {
                numAffected = Convert.ToInt32(dsHocVien.Tables[0].Rows[0]["Tong"].ToString());
            }
            else
            {
                numAffected = 0;
            }
            return numAffected;
        }
        //Lay danh sach lich su ngay bao cao
        public DataTable getHistoryDate23STruong(int NguonID,int TruongID)
        {
            DataTable dtData = new DataTable();
            SqlParameter[] parameters = {   new SqlParameter("@NguonID", SqlDbType.Int, 4),
                                            new SqlParameter("@TruongID", SqlDbType.Int, 4)
                                        };
            parameters[0].Value = NguonID;
            parameters[1].Value = TruongID;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS23STruong_GetDistinctDate", parameters, "TB_ReportS23STruong", connec);
            if (dsHocVien != null && dsHocVien.Tables[0] != null)
            {
                dtData = dsHocVien.Tables[0];
            }
            return dtData;
        }
        #endregion


        #region "Report 1a 1b"

        //Ca ham chuc nang cho Report1a
        public int insertReport1a(DateTime Ngay, int L1Tuan, int L1BanGiao, int L1NghiemThu, int KhoaHocID)
        {
            int numAffected = 0;
            // create the parameters
            SqlParameter[] parameters =  {	    
                                                new SqlParameter("@Ngay", SqlDbType.DateTime),
                                                new SqlParameter("@L1Tuan", SqlDbType.Int,4),
                                                new SqlParameter("@L1BanGiao", SqlDbType.Int,4),
                                                new SqlParameter("@L1NghiemThu", SqlDbType.Int,4),
                                                new SqlParameter("@KhoaHocID", SqlDbType.Int,4),
                                                new SqlParameter("@Output", SqlDbType.Int,4)
										 };
            // set the 0values
            parameters[0].Value = Ngay;
            parameters[1].Value = L1Tuan;
            parameters[2].Value = L1BanGiao;
            parameters[3].Value = L1NghiemThu;
            parameters[4].Value = KhoaHocID;
            parameters[5].Direction = ParameterDirection.Output;
            // run the procedure
            RunProcedure("sp_Report1a_Insert", parameters, out numAffected, connec);

            return numAffected;
        }
        public int updateReport1a(int ID, DateTime Ngay, int L1Tuan, int L1BanGiao, int L1NghiemThu, int KhoaHocID)
        {
            int numAffected = 0;
            // create the parameters
            SqlParameter[] parameters =  {	    
                                                new SqlParameter("@ID", SqlDbType.Int,4),
                                                new SqlParameter("@Ngay", SqlDbType.DateTime),
                                                new SqlParameter("@L1Tuan", SqlDbType.Int,4),
                                                new SqlParameter("@L1BanGiao", SqlDbType.Int,4),
                                                new SqlParameter("@L1NghiemThu", SqlDbType.Int,4),
                                                new SqlParameter("@KhoaHocID", SqlDbType.Int,4)                                      
										 };
            // set the 0values
            parameters[0].Value = ID;
            parameters[1].Value = Ngay;
            parameters[2].Value = L1Tuan;
            parameters[3].Value = L1BanGiao;
            parameters[4].Value = L1NghiemThu;
            parameters[5].Value = KhoaHocID;
            // run the procedure
            RunProcedure("sp_Report1a_Update", parameters, out numAffected, connec);

            return numAffected;
        }
        public DataSet loadReport1aAll(DateTime FromDate, DateTime ToDate)
        {
            SqlParameter[] parameters =  {	 new SqlParameter("@FromDate", SqlDbType.SmallDateTime),
                                             new SqlParameter("@ToDate", SqlDbType.SmallDateTime)  

                                         };
            // set the 0values
            parameters[0].Value = FromDate;
            parameters[1].Value = ToDate;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_Report1a_loadAll", parameters, "Tb_Report1a", connec);
            return dsHocVien;
        }

        //Ca ham chuc nang cho Report1b
        public int insertReport1b(DateTime Ngay, int L1Nhan, int KhongLienLac, int KhongDungDoiTuong, int VungKhac, int L2Len, int KhoaHocID)
        {
            int numAffected = 0;
            // create the parameters
            SqlParameter[] parameters =  {	    
                                                new SqlParameter("@Ngay", SqlDbType.DateTime),
                                                new SqlParameter("@L1Nhan", SqlDbType.Int,4),
                                                new SqlParameter("@KhongLienLac", SqlDbType.Int,4),
                                                new SqlParameter("@KhongDungDoiTuong", SqlDbType.Int,4),
                                                new SqlParameter("@VungKhac", SqlDbType.Int,4),
                                                new SqlParameter("@L2Len", SqlDbType.Int,4),
                                                new SqlParameter("@KhoaHocID", SqlDbType.Int,4),
                                                new SqlParameter("@Output", SqlDbType.Int,4)
										 };
            // set the 0values
            parameters[0].Value = Ngay;
            parameters[1].Value = L1Nhan;
            parameters[2].Value = KhongLienLac;
            parameters[3].Value = KhongDungDoiTuong;
            parameters[4].Value = VungKhac;
            parameters[5].Value = L2Len;
            parameters[6].Value = KhoaHocID;
            parameters[7].Direction = ParameterDirection.Output;
            // run the procedure
            RunProcedure("sp_Report1b_Insert", parameters, out numAffected, connec);

            return numAffected;
        }
        public int updateReport1b(int ID, DateTime Ngay, int L1Nhan, int KhongDungDoiTuong, int VungKhac, int L2Len, int KhoaHocID)
        {
            int numAffected = 0;
            // create the parameters
            SqlParameter[] parameters =  {	    
                                                new SqlParameter("@Ngay", SqlDbType.DateTime),
                                                new SqlParameter("@L1Nhan", SqlDbType.Int,4),
                                                new SqlParameter("@KhongDungDoiTuong", SqlDbType.Int,4),
                                                new SqlParameter("@VungKhac", SqlDbType.Int,4),
                                                new SqlParameter("@L2Len", SqlDbType.Int,4),
                                                new SqlParameter("@KhoaHocID", SqlDbType.Int,4)                         
										 };
            // set the 0values
            parameters[0].Value = ID;
            parameters[1].Value = Ngay;
            parameters[2].Value = L1Nhan;
            parameters[3].Value = KhongDungDoiTuong;
            parameters[4].Value = VungKhac;
            parameters[5].Value = L2Len;
            parameters[6].Value = KhoaHocID;
            // run the procedure
            RunProcedure("sp_Report1b_Update", parameters, out numAffected, connec);

            return numAffected;
        }
        public DataSet loadReport1bAll(DateTime FromDate, DateTime ToDate)
        {
            SqlParameter[] parameters =  {	 new SqlParameter("@FromDate", SqlDbType.SmallDateTime),
                                             new SqlParameter("@ToDate", SqlDbType.SmallDateTime)  

                                         };
            // set the 0values
            parameters[0].Value = FromDate;
            parameters[1].Value = ToDate;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_Report1b_loadAll", parameters, "Tb_Report1b", connec);
            return dsHocVien;
        }
  #endregion
        #region "Report S4"
        public DataTable getDataFirstPageReportS4(DateTime Date)
        {

            DataTable dtData = new DataTable();
            SqlParameter[] parameters =  {	 new SqlParameter("@Date", SqlDbType.DateTime)
                                         };
            // set the 0values
            parameters[0].Value = Date;
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS4_getDataFirstPage", parameters, "TB_ReportS4", connec);
            if (dsHocVien != null && dsHocVien.Tables[0].Rows.Count>0)
            {
                dtData = dsHocVien.Tables[0];
            }
            return dtData;
        }
        public DataTable loadLV5A8(int intLevelID)
        {
            SqlParameter[] parameters =  {	 new SqlParameter("@LevelID", SqlDbType.Int)
                                         };
            // set the 0values
            parameters[0].Value = intLevelID;
            DataTable dtData = new DataTable();
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS4_loadLV5A8", parameters, "Temp4", connec);
            if (dsHocVien != null && dsHocVien.Tables[0] != null)
            {
                dtData = dsHocVien.Tables[0];
            }
            return dtData;
        }
        //Lay danh sach lich su ngay bao cao
        public DataTable getHistoryDateS4()
        {
            DataTable dtData = new DataTable();
            // create the parameter
            DataSet dsHocVien = RunProcedure("sp_ReportS4_GetDistinctDate", "TB_ReportS4", connec);
            if (dsHocVien != null && dsHocVien.Tables[0] != null)
            {
                dtData = dsHocVien.Tables[0];
            }
            return dtData;
        }


        //public int insertReportS4( int SLT,int PhanTram,int	VB2BA,int CDBA,int KhacBA,int VB2FI,int	CDFI,int TCKhacFI,int TCFI,int KhacFI,int VB2FB	,int CDFB,int TCKhacFB,int TCFB	,int KhacFB	,int VB2IT,int CDIT	
        //                            ,int TCIT,int DIPIT	,int KhacIT	,int LevelID,DateTime Date, SqlTransaction sqlTransaction)
        //{
        //    int numAffected = 0;
        //    // create the parameters
        //    SqlParameter[] parameters =  {	    
        //                                        new SqlParameter("@SLT", SqlDbType.Int,4),
        //                                        new SqlParameter("@PhanTram", SqlDbType.Int,4),
        //                                        //QTKD
        //                                        new SqlParameter("@VB2BA", SqlDbType.Int,4),
        //                                        new SqlParameter("@CDBA", SqlDbType.Int,4),
        //                                        new SqlParameter("@KhacBA", SqlDbType.Int,4),
        //                                           //Ke toan
        //                                        new SqlParameter("@VB2FI", SqlDbType.Int,4),
        //                                        new SqlParameter("@CDFI", SqlDbType.Int,4),
        //                                        new SqlParameter("@TCKhacFI", SqlDbType.Int,4),
        //                                        new SqlParameter("@TCFI", SqlDbType.Int,4),
        //                                        new SqlParameter("@KhacFI", SqlDbType.Int,4),
        //                                        //TC-NH
        //                                        new SqlParameter("@VB2FB", SqlDbType.Int,4),
        //                                        new SqlParameter("@CDFB", SqlDbType.Int,4),
        //                                        new SqlParameter("@TCKhacFB", SqlDbType.Int,4),
        //                                        new SqlParameter("@TCFB", SqlDbType.Int,4),
        //                                        new SqlParameter("@KhacFB", SqlDbType.Int,4),
        //                                        //IT
        //                                        new SqlParameter("@VB2IT", SqlDbType.Int,4),
        //                                        new SqlParameter("@CDIT", SqlDbType.Int,4),
        //                                        new SqlParameter("@TCIT", SqlDbType.Int,4),
        //                                        new SqlParameter("@DIPIT", SqlDbType.Int,4),
        //                                        new SqlParameter("@KhacIT", SqlDbType.Int,4),


        //                                        new SqlParameter("@LevelID", SqlDbType.Int,4),
        //                                        new SqlParameter("@Date", SqlDbType.DateTime),
        //                                        new SqlParameter("@ID", SqlDbType.Int ,4)
        //                                 };
        //    // set the 0values
        //    parameters[0].Value = SLT;
        //    parameters[1].Value = PhanTram;
        //    //QTKD
        //    parameters[2].Value = VB2BA;
        //    parameters[3].Value = CDBA;
        //    parameters[4].Value = KhacBA;
        //    //Ke Toan
        //    parameters[5].Value = VB2FI;
        //    parameters[6].Value = CDFI;
        //    parameters[7].Value = TCKhacFI;
        //    parameters[8].Value = TCFI;
        //    parameters[9].Value = KhacFI;
        //    //TC-NH
        //    parameters[10].Value = VB2FB;
        //    parameters[11].Value = CDFB;
        //    parameters[12].Value = TCKhacFB;
        //    parameters[13].Value = TCFB;
        //    parameters[14].Value = KhacFB;
        //    //IT
        //    parameters[15].Value = VB2IT;
        //    parameters[16].Value = CDIT;
        //    parameters[17].Value = TCIT;
        //    parameters[18].Value = DIPIT;
        //    parameters[19].Value = KhacIT;

        //    parameters[20].Value = LevelID;
        //    parameters[21].Value = Date;
        //    parameters[22].Direction = ParameterDirection.Output;

        //    // run the procedure
        //    //RunProcedureWithTrans("sp_ReportS23_Insert", parameters, out numAffected, sqlTransaction);
        //    RunProcedure("sp_ReportS4_Insert", parameters, out numAffected, connec);
        //    return numAffected;
        //}
        public int insertReportS4(int SLT, int PhanTram, int VB2BA, int CDBA, int KhacBA, int VB2FI, int CDFI, int TCKhacFI, int TCFI, int KhacFI, int VB2FB, int CDFB, int TCKhacFB, int TCFB, int KhacFB, int VB2IT, int CDIT
                                    , int TCIT, int DIPIT, int KhacIT, int LevelID, DateTime Date)
        {
            int numAffected = 0;
            // create the parameters
            SqlParameter[] parameters =  {	    
                                                new SqlParameter("@SLT", SqlDbType.Int,4),
                                                new SqlParameter("@PhanTram", SqlDbType.Int,4),
                                                //QTKD
                                                new SqlParameter("@VB2BA", SqlDbType.Int,4),
                                                new SqlParameter("@CDBA", SqlDbType.Int,4),
                                                new SqlParameter("@KhacBA", SqlDbType.Int,4),
                                                   //Ke toan
                                                new SqlParameter("@VB2FI", SqlDbType.Int,4),
                                                new SqlParameter("@CDFI", SqlDbType.Int,4),
                                                new SqlParameter("@TCKhacFI", SqlDbType.Int,4),
                                                new SqlParameter("@TCFI", SqlDbType.Int,4),
                                                new SqlParameter("@KhacFI", SqlDbType.Int,4),
                                                //TC-NH
                                                new SqlParameter("@VB2FB", SqlDbType.Int,4),
                                                new SqlParameter("@CDFB", SqlDbType.Int,4),
                                                new SqlParameter("@TCKhacFB", SqlDbType.Int,4),
                                                new SqlParameter("@TCFB", SqlDbType.Int,4),
                                                new SqlParameter("@KhacFB", SqlDbType.Int,4),
                                                //IT
                                                new SqlParameter("@VB2IT", SqlDbType.Int,4),
                                                new SqlParameter("@CDIT", SqlDbType.Int,4),
                                                new SqlParameter("@TCIT", SqlDbType.Int,4),
                                                new SqlParameter("@DIPIT", SqlDbType.Int,4),
                                                new SqlParameter("@KhacIT", SqlDbType.Int,4),


                                                new SqlParameter("@LevelID", SqlDbType.Int,4),
                                                new SqlParameter("@Date", SqlDbType.DateTime),
                                                new SqlParameter("@ID", SqlDbType.Int ,4)
										 };
            // set the 0values
            parameters[0].Value = SLT;
            parameters[1].Value = PhanTram;
            //QTKD
            parameters[2].Value = VB2BA;
            parameters[3].Value = CDBA;
            parameters[4].Value = KhacBA;
            //Ke Toan
            parameters[5].Value = VB2FI;
            parameters[6].Value = CDFI;
            parameters[7].Value = TCKhacFI;
            parameters[8].Value = TCFI;
            parameters[9].Value = KhacFI;
            //TC-NH
            parameters[10].Value = VB2FB;
            parameters[11].Value = CDFB;
            parameters[12].Value = TCKhacFB;
            parameters[13].Value = TCFB;
            parameters[14].Value = KhacFB;
            //IT
            parameters[15].Value = VB2IT;
            parameters[16].Value = CDIT;
            parameters[17].Value = TCIT;
            parameters[18].Value = DIPIT;
            parameters[19].Value = KhacIT;

            parameters[20].Value = LevelID;
            parameters[21].Value = Date;
            parameters[22].Direction = ParameterDirection.Output;

            // run the procedure
            //RunProcedureWithTrans("sp_ReportS23_Insert", parameters, out numAffected, sqlTransaction);
            RunProcedure("sp_ReportS4_Insert", parameters, out numAffected, connec);
            return numAffected;
        }

        #endregion
    }
}